<!DOCTYPE html>
<html lang="en">
<head>
    {{include file="lib/page_head" /}}

    <style>
        table th{word-wrap:break-word;word-break:break-all;font-size:12px!important;}
        table td{word-wrap:break-word;word-break:break-all;font-size:12px!important;}
        .from_table .td_l,.from_table .td_r{font-size:14px!important;line-height: 25px;word-wrap:break-word;word-break:break-all}
        #search_form .form-control,#search_form .select5{width:100px;height:28px;padding:5px;}
        #search_form .layui-input-inline{width:auto;margin: 0;}
        #search_form .form-group{margin-right:0;margin-bottom: 5px;}
        #search_form .btn{height:30px;line-height:30px;padding:0 10px;}
    </style>
</head>

<body>



<!-- Preloader -->
<div id="preloader">
    <div id="status"><i class="fa fa-spinner fa-spin"></i></div>
</div>

<section>
    {{include file="lib/page_left" /}}
    <div class="mainpanel">

        {{include file="lib/page_header" /}}

        <div class="contentpanel" >
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="panel-btns">
                        <a href="" class="panel-close">×</a>
                        <a href="" class="minimize">−</a>
                    </div>
                    <h4 class="panel-title">用户卡列表</h4>
                </div>
                <div class="panel-body ">
                    <div id="info_list" class="form-inline">
                        <div class="btn-group">

                            <button class="btn btn-primary" onclick="add_order()">批量添加充值订单</button>
                            <!--<button class="btn btn-primary" onclick="set_cancel(0)">取消</button>-->
                            <button class="btn btn-primary" onclick="location.href = location.href;">刷新</button>
                        </div>
                        <div class="layui-form-item search_tools" style="margin-top:10px;" >
                            <form class="layui-form" id="search_form" action="" onsubmit="return false;">


                                <div style="display: inline-block;clear: both;">
                                    <button class="btn btn-primary" onclick="search()">查询</button>
                                    <button class="btn btn-default" onclick="search_reset()">取消</button>
                                </div>
                            </form>
                            <div class="well well-sm search_toogle"><span class="glyphicon glyphicon-chevron-down"></span></div>
                        </div>
                    </div>
                </div>
            </div>
        </div><!-- contentpanel -->

    </div><!-- mainpanel -->
    {{include file="lib/page_right" /}}
</section>
<div id="add_order" style="display: none;">
    <div class="layui-form-item" style="margin:10px;">
        <form>
            <input type="hidden" name="id" value="0">
            <div  class="form-group">
                <label >金额<span style="color:red;">(注意是每张卡的充值金额,100元的倍数)</span></label>
                <input type="text" name="amount"  placeholder="充值金额" class="form-control" value="0" data-ignore="true">
            </div>
            <div  class="form-group">
                <label >是否预存款支付</label>
                <input type="checkbox" name="is_pay"  placeholder="是否预存款支付" class="form-control" value="0" data-ignore="true">
            </div>
        </form>
    </div>
</div>

<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../js/jquery-migrate-1.2.1.min.js"></script>
<script src="../js/jquery-ui-1.10.3.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.sparkline.min.js"></script>
<script src="../js/toggles.min.js"></script>
<script src="../js/jquery.cookies.js"></script>
<script src="../js/jquery.tmpl.js"></script>
<script src="../js/custom.js"></script>
<script src="../layui/layui.js"></script>
<script src="../js/jquery.gritter.min.js"></script>
<script src="../js/form.beautify.js?t={{$version}}"></script>
<script src="../js/commen.js?t={{$version}}"></script>
<script src="../js/datatables.js?t={{$version}}"></script>
<link href="../css/ley.dialog.css" rel="stylesheet">
<script src="../js/ley.dialog.js?t={{$version}}"></script>
<script>
    layui.use(['laydate','laypage',"element"], function(){

    });
    var admin_id = "{{$ADMIN_ID}}";

    $(function () {


        $("#info_list").datatables({
            idField: 'card_no',
            mobile_field:["ck","company_name","card_no"],
            columns:[
                {field:'ck',checkbox:true },
                // {field:'id',title:'编号',width:50},
                {field:'company_name',title:'客户',width:50},
                {field:'card_no',title:'卡号',width:100},
                {field:'plate_number',title:'车牌号',width:100},
                {field:'card_balance',title:'卡内余额',width:100, formatter: function (value, row, index) {return "";}},
                {field:'pre_balance',title:'卡账户余额',width:100, formatter: function (value, row, index) {return "";}},
                {field:'status',title:'状态',width:30,formatter:function (value,row,index) {
                        if(value===1){
                            return "正常";
                        }else if(value===2){
                            return "禁用";
                        }else{
                            return "申请中";
                        }
                    }},
                {field:'ctime',title:'时间',width:100, formatter: function (value, row, index) {return getLocalTime(value) + "";}},
                {field:'operation',title:'操作',width:30,formatter:function (value,row,index) {
                        var text = "";
                        text += '<div class="btn-group"> ';
                        text += '<a data-toggle="dropdown" class="dropdown-toggle"> ';
                        text += '<i class="fa fa-cog"></i> ';
                        text += '</a> ';
                        text += '<ul role="menu" class="dropdown-menu pull-right"> ';
                        // text +='<li><a href="javascript:void 0;" onclick="get_card_balance(\''+row.card_no+'\')">查询余额</a></li> ' ;

                        text +='</ul> ';
                        text +='</div>';
                        return text;
                    }}


            ],
            ajax:{
                url:"/companyservice/ajax_card_list",
                parems:get_search_data(),
                callback:function (msg) {
                    check_table_list_data(msg);
                    check_parent_height();
                    if(msg.user_card_idle_list)
                    {
                        var options = "";
                        for(var i=0;i<msg.user_card_idle_list.length;i++)
                        {
                            var idle = msg.user_card_idle_list[i];
                            options += '<option value="'+idle.card_no+'">'+idle.card_no+'</option>';

                        }
                        $("#bind_new_card select[name='card_no']").html(options);
                    }
                }
            }
        });
    });
    function add_order(obj)
    {
        var row_list = $("#info_list").getRows(obj);
        if(row_list.length < 1)
        {
            openMsg("请选择一条记录");
            return false;
        }

        $("#add_order form")[0].reset();
        openDialog2({title:"充值",area: ['400', "400"],content:$("#add_order"),clone:true,before:function (layero) {

            },
            yes:function (index,layero) {
                var data = {};
                var amount = $("input[name='amount']",layero).val();
                data["row_list"] = row_list;
                data["amount"] = amount;
                data["is_pay"] = 0;
                if($("input[name='is_pay']:checked",layero).length>0)
                {
                    data["is_pay"] = 1;
                }
                AjaxCommen("GET","/companyservice/ajax_add_order",data,function (msg) {
                    if(msg.error === 0)
                    {
                        openMsg("成功");
                        layero.close();
                        search();
                    }
                });
            }
        });
    }
    function search()
    {
        var data = get_search_data();
        $("#info_list").setParems(data);
        $("#info_list").reload();

    }
    function search_reset() {
        $("#search_form")[0].reset();
        search();
    }
    function get_search_data() {
        var data = {};
        $('#search_form select,#search_form input').each(function () {
            var name = $(this).attr("name");
            if(name)
            {
                data[name] = $(this).val();
            }

        });
        return data;
    }
</script>

</body>
</html>
